package divideYvenceras;

import java.io.*;

public class MultiplicarMatrices {

	public static final int K = 3;

	public static void main(String args[]) throws Exception {
		BufferedReader cin = new BufferedReader(
				new InputStreamReader(System.in));
		int[][] A = {{1,2,3},{4,5,6},{7,8,9}};
		int[][] B = {{1,2,3},{4,5,6},{7,8,9}};
		int[][] C = new int[K][K];
		
		
		//String[] tresEnteros = cin.readLine().split(" ");
		int x = 3;//Integer.parseInt(tresEnteros[0]);
		int y = 3;//Integer.parseInt(tresEnteros[1]);
		int z = 3;//Integer.parseInt(tresEnteros[2]);
		/*
		for (int i = 0; i < x; i++) {
			String[] n_Enteros = cin.readLine().split(" ");
			for (int j = 0; j < y; j++) {
				A[i][j] = Integer.parseInt(n_Enteros[j]);
			}
		}
		for (int i = 0; i < y; i++) {
			String[] n_Enteros = cin.readLine().split(" ");
			for (int j = 0; j < z; j++) {
				B[i][j] = Integer.parseInt(n_Enteros[j]);
			}
		}
		*/
		for (int i = 0; i < x; i++) {
			for (int j = 0; j < z; j++) {
				C[i][j] = 0;
			}
		}
		
		multiplicaMatrices(A, B, x, 0, y, z, C);
		for (int i = 0; i < x; i++) {
			for (int j = 0; j < z - 1; j++) {
				System.out.print(C[i][j] + " ");
			}
			System.out.println(C[i][z - 1]);
		}
	}

	public static void sumaMatrices(int A[][], int B[][], int x, int z,
			int C[][]) {
		for (int i = 0; i < x; i++) {
			for (int j = 0; j < z; j++) {
				C[i][j] = A[i][j] + B[i][j];
			}
		}
	}

	public static void multiplicaMatrices(int A[][], int B[][], int x,
			int inicio_y, int final_y, int z, int C[][]) {
		int[][] M1 = new int[K][K];
		int[][] M2 = new int[K][K];
		int mitad_y = (inicio_y + final_y) / 2;
		if (inicio_y == final_y) {
			for (int i = 0; i < x; i++) {
				for (int j = 0; j < z; j++) {
					C[i][j] = A[i][mitad_y] * B[mitad_y][j];
				}
			}
		} else if (inicio_y <= final_y) {
			multiplicaMatrices(A, B, x, inicio_y, mitad_y, z, M1);
			multiplicaMatrices(A, B, x, mitad_y + 1, final_y, z, M2);
			sumaMatrices(M1, M2, x, z, C);
		}
	}
}
